var express = require('express');
var app = express()

var msbd = require("./msbd")
var discuss = require("./discuss")
var exam = require("./exam")
var user = require("./user")
var panel = require("./panel")
var brow = require("./browing")
var collect = require("./collect")
var part = require("./part")
var server = require("./server")


// 解决跨域问题
app.all('*', function (req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Content-Type", "text/json; charset=utf-8");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept,x-token");
    next()
})

app.get('/upload/*', function (req, res) {
    res.sendFile(__dirname + "/" + req.url)
})

app.use('/msbd', msbd)
app.use('/discuss', discuss)
app.use('/exam', exam)
app.use('/user', user)
app.use('/panel', panel)
app.use('/brow', brow)
app.use('/collect', collect)
app.use('/part', part)
app.use('/server', server)

var server = app.listen(3030, function () {
    var host = server.address().address
    var port = server.address().port
    console.log("应用实例，访问地址为 http://%s:%s", host, port)
})